load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test")

go_library(
    name = "admission",
    srcs = [
        "admission.go",
        "disk_bandwidth.go",
        "elastic_cpu_granter.go",
        "elastic_cpu_work_handle.go",
        "elastic_cpu_work_queue.go",
        "grant_coordinator.go",
        "granter.go",
        "io_load_listener.go",
        "kv_slot_adjuster.go",
        "pacer.go",
        "scheduler_latency_listener.go",
        "sequencer.go",
        "sql_cpu_overload_indicator.go",
        "store_token_estimation.go",
        "testing_knobs.go",
        "tokens_linear_model.go",
        "work_queue.go",
    ],
    importpath = "github.com/cockroachdb/cockroach/pkg/util/admission",
    visibility = ["//visibility:public"],
    deps = [
        "//pkg/base",
        "//pkg/raft/raftpb",
        "//pkg/roachpb",
        "//pkg/settings",
        "//pkg/settings/cluster",
        "//pkg/util",
        "//pkg/util/admission/admissionpb",
        "//pkg/util/buildutil",
        "//pkg/util/grunning",
        "//pkg/util/humanizeutil",
        "//pkg/util/log",
        "//pkg/util/metric",
        "//pkg/util/schedulerlatency",
        "//pkg/util/syncutil",
        "//pkg/util/timeutil",
        "//pkg/util/tracing",
        "@com_github_cockroachdb_errors//:errors",
        "@com_github_cockroachdb_logtags//:logtags",
        "@com_github_cockroachdb_pebble//:pebble",
        "@com_github_cockroachdb_redact//:redact",
        "@com_github_cockroachdb_tokenbucket//:tokenbucket",
    ],
)

go_test(
    name = "admission_test",
    srcs = [
        "disk_bandwidth_test.go",
        "elastic_cpu_granter_test.go",
        "elastic_cpu_work_handle_test.go",
        "elastic_cpu_work_queue_test.go",
        "granter_test.go",
        "io_load_listener_test.go",
        "replicated_write_admission_test.go",
        "scheduler_latency_listener_test.go",
        "sequencer_test.go",
        "store_token_estimation_test.go",
        "tokens_linear_model_test.go",
        "work_queue_test.go",
    ],
    data = glob(["testdata/**"]),
    embed = [":admission"],
    deps = [
        "//pkg/roachpb",
        "//pkg/settings/cluster",
        "//pkg/testutils/datapathutils",
        "//pkg/testutils/echotest",
        "//pkg/testutils/skip",
        "//pkg/util/admission/admissionpb",
        "//pkg/util/humanizeutil",
        "//pkg/util/leaktest",
        "//pkg/util/log",
        "//pkg/util/metric",
        "//pkg/util/syncutil",
        "//pkg/util/timeutil",
        "//pkg/util/tracing",
        "@com_github_cockroachdb_datadriven//:datadriven",
        "@com_github_cockroachdb_pebble//:pebble",
        "@com_github_cockroachdb_redact//:redact",
        "@com_github_cockroachdb_tokenbucket//:tokenbucket",
        "@com_github_guptarohit_asciigraph//:asciigraph",
        "@com_github_stretchr_testify//require",
    ],
)
